﻿<Window x:Class="iControl.Windows.SettingsWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:properties="clr-namespace:iControl.Properties"
	xmlns:iControl="clr-namespace:iControl"
    Title="Settings - iControl" Height="541" Width="640" AllowsTransparency="True" WindowStyle="None" FontFamily="Tahoma" Opacity="1" Background="#00FFFFFF" 
	Icon="..\Images\iControlIcon.ico" WindowStartupLocation="CenterScreen"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	mc:Ignorable="d" 
	xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna" ResizeMode="NoResize" 
	Loaded="SettingsWindow_Loaded" FocusManager.FocusedElement="{Binding ElementName=txtFadeInDuration}" Closing="SettingsWindow_Closing">
    <Window.Resources>

        <!-- Show Window Animation -->
        <Storyboard x:Key="ShowAnimation">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="{x:Null}" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                <SplineDoubleKeyFrame KeySpline="0,0,0.5,1" KeyTime="00:00:00.2000000" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>

        <!-- XClose Button Style -->
        <Style x:Key="CloseXButtonStyle" TargetType="{x:Type Button}">
            <Setter Property="FocusVisualStyle" Value="{DynamicResource ButtonFocusVisual}"/>
            <Setter Property="Background" Value="{DynamicResource ButtonNormalBackgroundFill}"/>
            <Setter Property="BorderBrush" Value="{DynamicResource ButtonBorder}"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <ControlTemplate.Resources>
                            <Storyboard x:Key="MouseOverAnimation">
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.BitmapEffect).(OuterGlowBitmapEffect.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                            <Storyboard x:Key="MouseOutAnimation">
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.BitmapEffect).(OuterGlowBitmapEffect.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </ControlTemplate.Resources>
                        <Image Source="..\Images\Skin\Close.png" x:Name="image">
                            <Image.BitmapEffect>
                                <OuterGlowBitmapEffect GlowColor="#FFFF0000" Opacity="0"/>
                            </Image.BitmapEffect>
                        </Image>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="BitmapEffect" TargetName="image">
                                    <Setter.Value>
                                        <OuterGlowBitmapEffect GlowColor="#FFFF0000" Opacity="1"/>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <iControl:KeyMapValueConverter x:Key="KeyMapValueConverter"/>
        <XmlDataProvider x:Name="dsKeyMaps" x:Key="KeyMapsDS" Source="D:\Projects\Dot NET\iControl\iControl\bin\Debug\KeyMaps.xmap" d:IsDataSource="True"/>
        <DataTemplate x:Key="KeyMapTemplate" x:Name="keyMapDataTemplate">
            <Grid Cursor="Hand" x:Name="pnlItem">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="220"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Label Content="{Binding Converter={StaticResource KeyMapValueConverter}, Mode=OneWay, XPath=@Command}" FontWeight="Bold" Grid.ColumnSpan="2"/>
                <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Grid.Column="1">
                    <Label x:Name="lblModifiers" Content="{Binding Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, XPath=@Modifiers}"/>
                    <Label x:Name="lblKey" Content="{Binding Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, XPath=@Key}"/>
                </StackPanel>
            </Grid>
        </DataTemplate>
    </Window.Resources>
    <Window.Triggers >
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource ShowAnimation}"/>
        </EventTrigger>
    </Window.Triggers>
    <!-- Window Body -->
    <Border Margin="0,0,0,0" BorderBrush="#CAFFFFFF" BorderThickness="1,1,1,1" CornerRadius="3,3,3,3" Background="#E5317699" MouseLeftButtonDown="DragWindow">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="27"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="6"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="6"/>
            </Grid.ColumnDefinitions>
            <Canvas HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="0" d:LayoutOverrides="GridBox" Grid.RowSpan="1" Grid.ColumnSpan="1" Margin="0,0,43,0">
                <Button x:Name="btnCloseX" Style="{DynamicResource CloseXButtonStyle}" Width="44" Height="18" Content="Button" Click="btnCloseX_Click"/>
            </Canvas>
            <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="1" BorderBrush="#FFDAE2E6" BorderThickness="1,1,1,1" CornerRadius="3,3,3,3" Margin="0,0,0,7">
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FF9ED5F0" Offset="0"/>
                        <GradientStop Color="#FFB6D1E1" Offset="1"/>
                        <GradientStop Color="#FFACBCC5" Offset="0.504"/>
                    </LinearGradientBrush>
                </Border.Background>
                <Grid Name="pnlMain" Margin="8,8,8,8">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="0.923*"/>
                        <RowDefinition Height="0.077*"/>
                    </Grid.RowDefinitions>
                    <GroupBox HorizontalAlignment="Stretch" VerticalAlignment="Top" Header="{x:Static properties:Resources.SettingsWindow_GeneralText}" BorderBrush="#FFFFFFFF" Padding="0,4,0,4" Height="142">
                        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="110.483">
                        	<Grid.ColumnDefinitions>
                        		<ColumnDefinition Width="0.77*"/>
                        		<ColumnDefinition Width="0.23*"/>
                        	</Grid.ColumnDefinitions>
                            <Label Content="{x:Static properties:Resources.SettingsWindow_FadeInDuration}" VerticalAlignment="Top" HorizontalAlignment="Left"/>
                            <TextBox Text="{Binding Path=FadeInDuration, Mode=TwoWay, Source={x:Static iControl:Settings.DefaultInstance}}" TextWrapping="Wrap" HorizontalAlignment="Left" Width="82" VerticalContentAlignment="Center" VerticalAlignment="Top" Margin="341.89,2,0,0" x:Name="txtFadeInDuration"/>
                            <Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="{x:Static properties:Resources.SettingsWindow_FadeOutDuration}" Margin="0,23.277,0,0"/>
                            <TextBox Text="{Binding Path=FadeOutDuration, Mode=TwoWay, Source={x:Static iControl:Settings.DefaultInstance}}" TextWrapping="Wrap" HorizontalAlignment="Left" Width="82" VerticalContentAlignment="Center" VerticalAlignment="Top" Margin="341.89,25.277,0,0" x:Name="txtFadeOutDuration"/>
                            <CheckBox IsChecked="{Binding Path=ShowPlaybackStatus, Mode=TwoWay, Source={x:Static iControl:Settings.DefaultInstance}}" VerticalAlignment="Top" Content="{x:Static properties:Resources.SettingsWindow_ShowPlaybackStatus}" Margin="5,52,217.59,0" x:Name="chkShowPlaybackStatus" d:LayoutOverrides="Width"/>
                            <Label VerticalAlignment="Bottom" Content="{x:Static properties:Resources.SettingsWindow_OneClickIcon}" Margin="0,0,121.03,17.516" d:LayoutOverrides="Width, Height"/>
                            <Label VerticalAlignment="Bottom" Content="{x:Static properties:Resources.SettingsWindow_TwoClickIcon}" Margin="0,0,121.03,-3" d:LayoutOverrides="Width, Height"/>
                        </Grid>
                    </GroupBox>
                    <GroupBox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="{x:Static properties:Resources.SettingsWindow_ShortcutsText}" BorderBrush="#FFFFFFFF" Padding="0,4,0,4" Margin="0,146,0,0">
                        <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <TextBlock Text="{x:Static properties:Resources.SettingsWindow_KeyboardAssignInfo}" TextWrapping="Wrap" Margin="0,0,0,5"/>
                            <Button HorizontalAlignment="Right" Margin="0,-10,5,0" x:Name="btnChangeShortcuts" Style="{DynamicResource LinkLabelStyle}" Content="Let me change shortcuts" Foreground="#FF0000FF" Click="btnChangeShortcuts_Click"/>
                            <ListBox IsSynchronizedWithCurrentItem="True" Background="{x:Null}" ItemsSource="{Binding Mode=Default, Source={StaticResource KeyMapsDS}, XPath=/KeyMaps/KeyMap}" ItemTemplate="{DynamicResource KeyMapTemplate}" x:Name="lstKeyMaps" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="235"  />
                        </StackPanel>
                    </GroupBox>
                    <Button HorizontalAlignment="Right" Content="Cancel" Grid.Row="1" Margin="0,0,8,4" Height="21" Width="70" x:Name="btnCancel" Click="btnCancel_Click" VerticalAlignment="Bottom"/>
                    <Button HorizontalAlignment="Right" Margin="0,0,82,4" Width="70" Height="21" Content="OK" Grid.Row="1" x:Name="btnOK" Click="btnOK_Click" VerticalAlignment="Bottom"/>
                    <Button HorizontalAlignment="Left" Content="{x:Static properties:Resources.SettingsWindow_RestoreToDefault}" d:LayoutOverrides="Height" Grid.Row="1" Margin="6,7.478,0,4" Foreground="#FF0000FF" x:Name="btnResoreDefaults" Click="btnResoreDefaults_Click" Style="{DynamicResource LinkLabelStyle}"/>
                </Grid>

            </Border>
            <Image HorizontalAlignment="Left" Width="20" Grid.Column="1" Source="..\Images\iControlIcon24.png" Stretch="Fill" VerticalAlignment="Center" Height="20" Margin="0,0,0,0"/>
            <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" TextWrapping="Wrap" Grid.Row="0" d:LayoutOverrides="HorizontalAlignment, GridBox" Grid.Column="1" Margin="27,0,0,0" Foreground="#FFFFFFFF" FontFamily="Tahoma" x:Name="lblWindowTitle"/>
        </Grid>
    </Border>
</Window>
